package com.lc202406;

public class Solution1154 {
    public int dayOfYear(String date) {
        String[] arr = date.split("-");
        int month = Integer.parseInt(arr[1]);
        int year = Integer.parseInt(arr[0]);
        int day = Integer.parseInt(arr[2]);
        int[] nums = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};
        for (int i = 0; i < month - 1; i++) {
            day += nums[i];
        }
        if (month > 2 && (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))) {
            day++;
        }
        return day;
    }
}
